package com.taiyuan.tongcheng.adapter;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.baidu.mapapi.search.core.PoiInfo;
import com.baidu.mapapi.search.sug.SuggestionResult.SuggestionInfo;
import com.tytc56.user.R;

public class SearchInfoAdapter  extends BaseAdapter {
	
	private List<PoiInfo> pointList=new ArrayList<PoiInfo>();
	private Context context;
	private LayoutInflater layoutInflater;
	
	public SearchInfoAdapter(Context context ,List<PoiInfo> pointList){
		this.pointList=pointList;
		this.context=context;
		this.layoutInflater = LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		return pointList.size();
	}

	@Override
	public Object getItem(int position) {
		return pointList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ZuJian zuJian = null;
		if (convertView == null) {
			zuJian = new ZuJian();
			convertView = layoutInflater.inflate(R.layout.listview_point_info,
					null);
			zuJian.poiName=(TextView)convertView.findViewById(R.id.tv_mapsearch_name);
			zuJian.poiAdd=(TextView)convertView.findViewById(R.id.tv_mapsearch_add);
			convertView.setTag(zuJian);
		} else {
			zuJian = (ZuJian) convertView.getTag();
		}
		zuJian.poiName.setText(pointList.get(position).name);
		zuJian.poiAdd.setText(pointList.get(position).address);
		return convertView;
	}

	
	public final class ZuJian {
		public TextView poiName;
		public TextView poiAdd;
	}
	
}
